/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apt.Bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apt.connectDB.MyConnect;

/**
 *
 * @author MinhThang
 */
public class author_join_lecture_bean extends org.apache.struts.action.ActionForm {
    
    private String txtAuthorID;
    private String ddlLecture;

    /**
     * @return
     */
    
    public author_join_lecture_bean() {
        super();
        // TODO Auto-generated constructor stub
    }
    public boolean CreateAuthorJoin(){
        //Insert data to AuthorJoin table
        String sql="INSERT INTO [dbo].[AuthorJoin] ([LectureID], [AuthorID], [Status], [Description]) VALUES (?, ?, ?, ?)";
        Connection conn=null;
        PreparedStatement ps=null;
        try {
            conn=MyConnect.getConnection();
            ps=conn.prepareCall(sql);
            ps.setInt(1, Integer.parseInt(getDdlLecture()));
            ps.setInt(2, Integer.parseInt(getTxtAuthorID()));
            ps.setBoolean(3, true);
            ps.setString(4, "");
            ps.executeUpdate();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    /**
     * @return the txtAuthorID
     */
    public String getTxtAuthorID() {
        return txtAuthorID;
    }

    /**
     * @param txtAuthorID the txtAuthorID to set
     */
    public void setTxtAuthorID(String txtAuthorID) {
        this.txtAuthorID = txtAuthorID;
    }

    /**
     * @return the ddlLecture
     */
    public String getDdlLecture() {
        return ddlLecture;
    }

    /**
     * @param ddlLecture the ddlLecture to set
     */
    public void setDdlLecture(String ddlLecture) {
        this.ddlLecture = ddlLecture;
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    
}
